#ifndef TCPSERVER_H
#define TCPSERVER_H

#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <sys/epoll.h>
#include <unistd.h>
#include <sys/types.h>

#include "config.h"
#include "handler.h"
#include "tcpsocket.h"

class EventLoop;

class TcpServer: public Handler
{
public:
    TcpServer(EventLoop *loop, int port);
    ~TcpServer();

    int startListen(void);
    virtual void newTcpConnection(TcpSocket *socket){}

protected:
    int m_port;
    TCPSocketMap m_socketMap;

private:
    EventLoop *m_evLoop;
    void handleAccept();
};

#endif // TCPSERVER_H
